﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;

namespace SNSComponent.SNSProvider
{
    public interface IProvider
    {
        string ProviderName { get; }

        bool IsAuthed { get; }

        Task<ResultData> ShareStatus(string content);

        Task<ResultData> ShareStatus(string content, Stream image);

        Task<ResultData> ShareStatus(string content, Uri imageUri);

        Task<ResultData> ShareStatusWithLocation(string content);

        Task<ResultData> ShareStatusWithLocation(string content, Stream image);

        Task<ResultData> ShareStatusWithLocation(string content, Uri imageUri);

        void GetToken();

        event EventHandler<ResultDataEventArgs> GetTokenComplated;

        void CleanToken();

        event EventHandler TokenChanged;

    }

    
    public class ResultDataEventArgs : EventArgs
    {
        public ResultData ResultData {get; private set;}

        public ResultDataEventArgs(ResultData data)
        {
            ResultData =data;
        }

    }

    public class ResultData
    {
        public ResultState ResultState { get; private set; }

        public Exception Error { get; private set; }

        public IDictionary Data { get; private set; }

        public IProvider Provider { get; private set; }

        public ResultData(IProvider provider,ResultState resultState, Exception ex, IDictionary data)
        {
            ResultState = resultState;
            Error = ex;
            Data = data;
            Provider = provider;
        }

        public ResultData(IProvider provider, ResultState resultState, Exception ex)
        {
            ResultState = resultState;
            Error = ex;
            Data = new System.Collections.Generic.Dictionary<string, object>();
            Provider = provider;
        }

        public ResultData(IProvider provider,ResultState resultState)
        {
            ResultState =resultState;
            Data = new System.Collections.Generic.Dictionary<string, object>();
            Error = null;
            Provider = provider;
        }

    }

    public enum ResultState
    {
        Success,
        UserCanceled,
        InvalidVerifyCode,
        InvalidToken,
        InvalidAPIKey,
        InvalidAPKSecet,
        RedirectUriMismatch,
        RequestForbidden,
        UnknowError
    }
}
